﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@include file="../common/base.jsp"%>
<title>无标题页</title>
<link rel="stylesheet" type="text/css"
	href="${ctx}/staticweb/css/index.css">
<script language="javascript" type="text/javascript">
$(function() {
	$(".outBtn").on("click",function(){
        var mid = $(this).attr("value");
        var outCount = $(this).parents("tr:first").find("input[name='outCount']").val();
        var price = $(this).parents("tr:first").find("input[name='price']").val();
        var name = $(this).parents("tr:first").find("input[name='name']").val();
        var outTime = $(this).parents("tr:first").find("input[name='outTime']").val();
        
        var rowObj = $(this).parents("tr:first").find("td.lostCount");
        var lostCount = $(rowObj).text();
        
/*           $.ajax({
        	type: "post",
        	url: "${ctx}/store/DeleteGoods.json",
        	async : true,
        	contentType: "application/json",
        	dataType: "json",
        	data: {
                mid:mid,
                outCount:outCount,
                price:price,
                name:name,
                outTime:outTime
        	},
        	success: function (data) {
        		if(data.result == '1'){
        			alert("出库成功");
        		}else{
        			alert("出库失败");
        		}
        	},
        	error:function(XMLHttpRequest, textStatus, errorThrown){
        		alert("系统错误");
        		 alert(XMLHttpRequest.status);
        		 alert(XMLHttpRequest.readyState);
        		 alert(textStatus);
        		 alert(errorThrown);
        	}
        });
 */
          $.post("${ctx}/store/DeleteGoods.json",{
            mid:mid,
            outCount:outCount,
            price:price,
            name:name,
            outTime:outTime
            },
            function(data,status){
            	//alert("数据：" + data + "\n状态：" + status);
                 if(data.result == '1'){
                	alert("出库成功");
                	var lostNum = parseInt(lostCount) - parseInt(outCount);
                	$(rowObj).html(lostNum);
                }else{
                	alert("出库失败");
                }
        });
	});
});
</script>
</head>
<body class="mian_bj">
	<form action="${ctx}/store/toDeleteGoods.do" method="post">
		<div class="mian_top_01">
			<div class="mian_top_r"></div>
			<div class="mian_b">
	            <div class="mian_b1">
	                <p class="mian_b1_sousuo">
	                    <input name="sbrand" placeholder="品牌" type="text" value="${sbrand}">
	                </p>
	                <p class="mian_b1_sousuo">
	                    <input name="smodel" placeholder="型号" type="text" value="${smodel}">
	                </p>
	                <p class="mian_b1_sousuo">
	                    <input name="scolor" placeholder="颜色" type="text" value="${scolor}">
	                </p>
	                <p class="mian_b1_sousuo">
	                    <input name="ssize" placeholder="尺码" type="text" value="${ssize}">
	                </p>
	                <p style="width:48px;height: 26px;float: left;margin-top: 13px;margin-left: 30px;">
	                   <button type="submit">搜索</button>
	                </p>
	            </div>
				<table width="100%" border="0" cellpadding="0" cellspacing="0"
					class="mian_b_bg">
					<tr>
						<td width="10%" class="mian_b_bg_lm"><span></span>品牌</td>
						<td width="5%" class="mian_b_bg_lm"><span></span>型号</td>
						<td width="5%" class="mian_b_bg_lm"><span></span>颜色</td>
						<td width="5%" class="mian_b_bg_lm"><span></span>尺码</td>
						<td width="5%" class="mian_b_bg_lm"><span></span>剩余件数</td>
						<td width="8%" class="mian_b_bg_lm"><span></span>出库件数</td>
						<td width="8%" class="mian_b_bg_lm"><span></span>零售价</td>
						<td width="8%" class="mian_b_bg_lm"><span></span>分店名</td>
						<td width="8%" class="mian_b_bg_lm"><span></span>出货时间</td>
						<td width="8%" class="mian_b_bg_lm"><span></span>操作</td>
					</tr>
					<c:choose>
						<c:when test="${not empty pagination.data}">
							<c:forEach items="${pagination.data}" var="rowData">
								<tr>
									<td>${rowData.brand}</td>
									<td>${rowData.model}</td>
									<td>${rowData.color}</td>
									<td>${rowData.size}</td>
									<td class="lostCount">${rowData.count}</td>
									<td><input name="outCount" style="width:90%;height:90%" type="text"></td>
									<td><input name="price" style="width:90%;height:90%" type="text"></td>
									<td><input name="name" style="width:90%;height:90%" type="text"></td>
									<td><input name="outTime" style="width:90%;height:90%" type="text"></td>
									<td><button type="button" class="outBtn" value="${rowData.id}" style="width:90%;">出库</button></td>
								</tr>
							</c:forEach>
						</c:when>
						<c:otherwise>
							<tr>
								<td colspan="10">没有库存</td>
							</tr>
						</c:otherwise>
					</c:choose>
				</table>
			</div>
			<div style="padding-left: 100px;margin:10px;">${pagination.pageStr}</div>
		</div>
	</form>
</body>
</html>
